package com.stox.ui.javafx.charting.widget;

import javafx.scene.canvas.Canvas;

public class ResizableCanvas extends Canvas {

	private final Chart<?> chart;
	
	public ResizableCanvas(Chart<?> chart) {
		this.chart = chart;
		widthProperty().addListener(evt -> chart.getChartingView().update());
        heightProperty().addListener(evt -> chart.getChartingView().update());
	}

	public Chart<?> getChart() {
		return chart;
	}
	
	 @Override
     public boolean isResizable() {
         return true;
     }

     @Override
     public double prefWidth(double height) {
         return getWidth();
     }

     @Override
     public double prefHeight(double width) {
         return getHeight();
     }
	
}
